package cn.wolfcode.wolf2w.exception;

import cn.wolfcode.wolf2w.util.JsonMsg;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.http.HttpServletResponse;

/**
 * 统一异常处理
 */
@ControllerAdvice
public class MgrUnifiedException {


    @ExceptionHandler(LogicalException.class)
    public Object LogicalException(Exception e, HttpServletResponse response){
        e.printStackTrace();
        response.setContentType("application/json;charset=utf-8");
        return new JsonMsg(false,e.getMessage());
    }
}
